package com.ayu.shortlink.engine.common.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * Redis 扣减库存失败的枚举类
 */
@RequiredArgsConstructor
public enum RedisStockDecrementErrorEnum {
    STOCK_NOT_ENOUGH(1,"库存不足"),
    STOCK_LIMIT_OBTAIN(2,"用户领取已达上限");

    @Getter
    private final int code;
    @Getter
    private final String message;

    public static String fromType(long code){
        for (RedisStockDecrementErrorEnum method : RedisStockDecrementErrorEnum.values()) {
            if(method.getCode() == code){
                return method.message;
            }
        }
        return "该类型不存在";
    }
}
